<?php
/**
 * Created by PhpStorm.
 * User: 独行侠
 * Date: 2018/3/9
 * Time: 20:45
 */

namespace App\Services\Orders;


use App\Repositories\Order\RefundDetailRepository;

class RefundDetailService
{

    protected $refundDetailRepository;

    public function __construct(RefundDetailRepository $refundDetailRepository)
    {
        $this->refundDetailRepository = $refundDetailRepository;
    }

    /**
     * 检查订单商品是否已退款
     * @author Min
     * @param int $order_id
     * @param int $goods_id
     * @param int $goods_num
     * @return int
     */
    public function checkRefund($order_id=0, $goods_id=0, $goods_num=0){
        $refund_num = $this->refundDetailRepository->getRefundDetailSumByGoodsId($order_id, $goods_id);

        if($refund_num >= $goods_num){
            return 1;
        }else{
            return 0;
        }
    }

}